package com.util;

import com.dns.customers.AppPage;
import com.dns.framework.dao.DaoManager;
import org.springframework.beans.factory.annotation.Autowired;

import javax.sql.DataSource;

/**
 * 1、唯一性序列生成器
 * 2、JDBC MySQL 数据源引入
 *
 * @author :  yulei
 * @data :  2018/5/23 15:14
 * @Version :  1.0
 **/

public class DataSourceUtil  extends AppPage {


    @Autowired
    protected DaoManager daoManager;

    @Autowired
    DataSource dataSource;

    /**
     * 生成日志流水ID
     * 规则: 年月日时分秒+3位随机数+3位随机数
     * 201808010401888000
     */

    public static String getLogId(){
        String time= DateUtil.getDateTimeStr();
        String random1 = String.valueOf((int)(Math.random()*900)+100);
        String random2 =String.valueOf((int)(Math.random()*900)+100);
        return time+random1+random2;
    }

    /**
     * 订单ID
     * @return
     */
    public static String getOrderId(){
        String time= DateUtil.getDateTimeStr();
        String random1 = String.valueOf((int)(Math.random()*900)+100);
        return time+random1;
    }


    public static void main(String[] args) {
        System.out.println( getOrderId());
    }
}
